<?php
class CV_Filter_Callback_Args implements Zend_Filter_Interface{
	protected $_args_before;
	protected $_args_after;
	protected $_callback;
	/**
	 * @param callback $callback
	 */
	public function __construct( $callback, $args_before = array(), $args_after = array() ){
		$this->_callback = $callback;
		if( is_array($args_after) ){
			$this->_args_after = array_values( $args_after );
		} elseif( $args_after === NULL ){
			$this->_args_after = array();
		} else {
			$this->_args_after = array( $args_after );
		}
		if( is_array($args_before) ){
			$this->_args_before = array_values( $args_before );
		} elseif( $args_before === NULL ){
			$this->_args_before = array();
		} else {
			$this->_args_before = array( $args_before );
		}
	}
	public function filter( $value ){
		$func_args = func_get_args();
		$args = array_merge(
			$this->_args_before,
			$func_args,
			$this->_args_after
		);
		return call_user_func_array( $this->_callback, $args );
	}
}